import { defineConfig } from "vite";
import vue from "@vitejs/plugin-vue";

import AutoImport from "unplugin-auto-import/vite";
import Components from "unplugin-vue-components/vite";
import { ElementPlusResolver } from "unplugin-vue-components/resolvers";

const path = require('path');

const pathResolve = (dir: string): string => {
  return path.resolve(__dirname, ".", dir);
};
// https://vitejs.dev/config/
export default defineConfig({
  resolve: {
    alias: {
      "@": pathResolve("./src"),
    },
  },
  plugins: [
    vue(),
    AutoImport({
      resolvers: [ElementPlusResolver()],
    }),
    Components({
      resolvers: [ElementPlusResolver()],
    }),
  ],
  server:{
    // port: 3000,
    // open: false, //自动打开 
    // base: "./ ", //生产环境路径
    proxy:{
      '/Api/': {
        target: 'https://api.weixin.qq.com/',
        secure: false,
        changeOrigin: true,
        rewrite: (path) => {
          console.log(path)
          // return ''
          return path.replace(/^\/Api\//, '')
        }
      },
      // "/api":"https://api.weixin.qq.com"
    }
  }
  
});
